package com.learn.xxl.job;

import com.mate.cloud.job.annotation.XxlRegister;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

@Slf4j
@Component
public class UserJob {

    /**
     * 每2分钟执行一次
     * @param param
     * @return
     */
    @Transactional
    @XxlJob("testJob")
    @XxlRegister(cron = "0 */2 * * * ?",jobDesc = "测试job")
    public ReturnT<String> testJob(String param) {
       log.info("每2分钟执行一次 hello xxl job",param);
        return ReturnT.SUCCESS;
    }
    /**
     * 每5分钟执行一次
     * @param param
     * @return
     */
    @XxlJob("testJob222")
    @XxlRegister(cron = "0 */5 * * * ?",triggerStatus = 1)
    public ReturnT<String> testJob2(String param) {
        log.info("每5分钟执行一次 hello xxl job",param);
        return ReturnT.SUCCESS;
    }
    /**
     * 每10分钟执行一次
     * @param param
     * @return
     */
    @XxlJob("testJob444")
    @XxlRegister(cron = "0 */10 * * * ?")
    public ReturnT<String> testJob4(String param) {
        log.info("每10分钟执行一次 hello xxl job",param);
        return ReturnT.SUCCESS;
    }
}
